package gameoflife.cluster;

import java.util.ArrayList;

public enum Range {
	N1(0, 1),
	NE1(1, 1),
	E1(1, 0),
	SE1(1, -1),
	S1(0, -1),
	SW1(-1, -1),
	W1(-1, 0),
	NW1(-1, 1),

	N2(0, 2),
	NNE2(1, 2),
	NE2(2, 2),
	ENE2(2, 1),
	E2(2, 0),
	ESE2(2, -1),
	SE2(2, -2),
	SSE2(1, -2),
	S2(0, -2),
	SSW2(-1, -2),
	SW2(-2, -2),
	WSW2(-2, -1),
	W2(-2, 0),
	WNW2(-2, 1),
	NW2(-2, 2),
	NNW2(-1, 2);

	public static final Range[] ALL = Range.values();

	public final int x, y;
	public Range[] reachable;

	Range(int x, int y) {
		this.x = x;
		this.y = y;
	}

	static {
		for (Range from : ALL) {
			ArrayList<Range> list = new ArrayList<Range>();
			for (Range to : ALL) {
				if (Math.abs(to.x + from.x) > 2 || Math.abs(to.y + from.y) > 2) {
					list.add(to);
				}
			}
			from.reachable = list.toArray(new Range[list.size()]);
		}
	}	

}
